#ifndef __LOGINSIGNUP_H_
#define __LOGINSIGNUP_H_
#include <map>
#include <string>
#include <fstream>
#include "Scene.h"
#include "Object.h"
#include "Scene.h"
//!
extern Player p;

using namespace std;
using CStrRef = const std::string &;

/* 抽象界面类 */
class Interface     
{
public:
    virtual void show() = 0;
    virtual ~Interface() {}
};

class DataLoader 
{
public:
    static bool LoadGameData(Player& player, std::vector<Monster>& monsters, std::vector<TreasureBox>& treasureBoxes, const std::string& filePath);
    
private:
    static bool LoadPlayerData(Player& player, const std::string& filePath);
    static bool LoadMonsterData(std::vector<Monster>& monsters, const std::string& filePath);
    static bool LoadTreasureBoxData(std::vector<TreasureBox>& treasureBoxes, const std::string& filePath);
};

/* 登录 */
class Login : public Interface
{
public:
    Login();
    /* 登录账号*/
    bool login(CStrRef UserName, CStrRef Passwd);

/* 账号管理接口 */
    /* 删除账号 */
    void RemoveUser(CStrRef UserName);
    /* 修改密码 */
    void ChangPasswd(CStrRef UserName,CStrRef Passwd);
    /*储存账号信息到文件*/
    void Save();
    void DataShow(Player &p);
    void show();
    map<std::string,std::string> &GetUserList()
    {
        return UserList;
    }
    void PlayGame(Player &p);
    

    bool LoadGameDataAfterLogin(Player& player, std::vector<Monster>& monsters, std::vector<TreasureBox>& treasureBoxes) 
    {
        return DataLoader::LoadGameData(player, monsters, treasureBoxes, "save_data");
    }
    
private:
    std::map<std::string,std::string> UserList;
};

/* 注册账号 */
class SignUp : public Interface
{
public:
    void show();
    /* 获得用户名 */
    static string GetUserName(Player & p)
    {
        return p.GetName();
    }
    /* 保存文件 */
    void Save(CStrRef UserName, CStrRef passwd, CStrRef filePath);
};

/*单例模式创建界面*/
class Screen : public Interface
{
public:
    void show();
    static Screen& getInstance() 
    {
        static Screen instance; // 静态局部变量确保单例
        return instance;
    }
private:
    Screen();
    ~Screen();
    // ~Screen() = default;                    //默认析构函数                              
    std::map<int, Interface*> faceList;     //定义成员变量
};





#endif